package com.yunkeji.api.sign.controller;

import com.yunkeji.api.sign.service.SignService;
import com.yunkeji.api.sign.vo.SignConfigVo;
import com.yunkeji.common.core.controller.BaseController;
import com.yunkeji.common.core.domain.R;
import com.yunkeji.common.helper.LoginHelper;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 签到
 *
 * @author 老张
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/v1/sign")
public class SignController extends BaseController {
    private final SignService signService;

    /**
     * 获取签到列表
     *
     * @author 老张
     */
    @PostMapping("/config")
    public R<SignConfigVo> config() {
        return R.ok(signService.config());
    }

    /**
     * 开始签到
     *
     * @author 老张
     */
    @PostMapping("/toSign")
    public R toSign() {
        signService.toSign(LoginHelper.getUserId());
        return R.ok();
    }
}
